<?php 
	if ((!defined("ADMIN-AREA")) || (!in_array($_GET['showview'],$_SESSION['access']))) {
		die("No data");
	} else {
		unset($_SESSION['access']);
	}

	include_once "modul/funct_stat.php";
	
	if (ACT=="edit") {
		$kode = (int) $_GET['kode'];
		$sql = "SELECT * FROM tbl_upload WHERE idx='".$kode."' ORDER BY tanggal DESC LIMIT 1";
		$qry = mysql_query($sql);
		$row = mysql_fetch_object($qry);

		$namax = explode("[spasi]",$row->data);
		$nama = $namax[1];
		$ukuran = $namax[2];
		$thum = $namax[0];
		$tipe = $row->tipe;
		$deskripsi = $namax[3];
		$form_stat = "Edit";
	} else {
		$form_stat = "Input";
		$target = "_self";
	}
	$opt_target = array("_parent", "_top", "_blank", "_self");

	if ((ACT=="tambah") || (ACT=="edit")) {
?>
<form action="<?php echo $path; ?>ver_foto_galeri.php?show=<?php echo $_GET['show']; ?>&amp;showview=<?php echo $_GET['showview']; ?>" method="post" enctype="multipart/form-data" name="form1" onsubmit="MM_validateForm('<?php echo $FG_TITLE; ?>','','R','<?php echo $FG_DESC; ?>','','R');return document.MM_returnValue">
  <table width="95%" border="0" align="center" cellpadding="4" cellspacing="0" class="content-arial">
    <tr> 
      <td width="50%" rowspan="2" valign="top"> <table width="95%" border="0" align="right" cellpadding="4" cellspacing="0" class="content-arial">
          <tr> 
            <td width="34%" valign="middle" nowrap="nowrap"><div align="right"><?php echo $FG_TITLE; ?></div></td>
            <td width="3%" valign="middle"><div align="center">:</div></td>
            <td width="63%" valign="middle"><div align="left"> 
                <input name="nama" type="text" id="<?php echo $FG_TITLE; ?>" size="30" value="<?php echo $nama; ?>" class="input-title" />
              </div></td>
          </tr>
          <tr> 
            <td align="left" valign="top" nowrap="nowrap"><div align="right"><?php echo $FG_DESC; ?></div></td>
            <td align="left" valign="top"><div align="center">:</div></td>
            <td><textarea name="deskripsi" cols="30" rows="5" id="<?php echo $FG_DESC; ?>"><?php echo $deskripsi; ?></textarea></td>
          </tr>
          <tr> 
            <td nowrap="nowrap"><div align="right"><?php echo $FG_FILE; ?></div></td>
            <td><div align="center">:</div></td>
            <td><input name="upbanner" type="file" id="<?php echo $FG_FILE; ?>"></td>
          </tr>
          <tr> 
            <td nowrap="nowrap">&nbsp;</td>
            <td>&nbsp;</td>
            <td><div align="left"> 
              <input type="submit" name="submit" id="submit" value="<?php echo $DEV_CTRL_SUBMIT; ?>" />
              <input type="reset" name="Reset" value="<?php echo $DEV_CTRL_RESET; ?>" />
              <input name="act_ver" type="hidden" id="act_ver" value="<?php echo strtolower($form_stat); ?>">
              <input name="kode" type="hidden" id="kode" value="<?php echo $kode; ?>">
                <input name="nama_hid" type="hidden" id="nama_hid" value="<?php echo $thum; ?>">
            </div></td>
          </tr>
      </table></td>
      <td width="58%" valign="top"><?php
		if (file_exists("data/galeri/FG".$thum.".".$tipe)) {
			echo $FG_TIPS_CURR_FILE;
			echo "<img src=\"data/galeri/FG".$thum.".".$tipe."\" border='0'>";
		};
	?></td>
    </tr>
    <tr>
      <td valign="top">&nbsp;</td>
    </tr>
  </table>
</form>
<?php
		} else {
	echo $queryData->cari_form($FG_SEARCH);
	$caridata = $queryData->cari_padaku("data","tipe");
?>
<table border="0" align="center" cellpadding="2" cellspacing="2" class="imagesSUB">
  <tr> 
    <th width="150" height="30" class="imagesSUB"> <div align="center"><?php echo $FG_TITLE; ?></div></th>
    <th width="120" class="imagesSUB"> <div align="center"><?php echo $FG_TIME; ?></div></th>
    <th width="50" class="imagesSUB"> <div align="center"><?php echo $FG_FILE; ?></div></th>
    <th width="50" class="imagesSUB"><div align="center"><?php echo $DEV_ACTION; ?></div></th>
  </tr>
  <?php	
		if (isset($_SESSION['isroot'])) {
			$sql1 = "SELECT * FROM tbl_upload WHERE RIGHT(`data`,2)='FG' ".$caridata." ORDER BY tanggal DESC LIMIT ".$limitdown.",10";
		} else {
			$sql1 = "SELECT * FROM tbl_upload WHERE RIGHT(`data`,2)='FG' ".$caridata." AND author='".strtolower($_SESSION['author'])."' ORDER BY tanggal DESC LIMIT ".$limitdown.",10";
;
		}
		$qry1 = mysql_query($sql1);
		$numrow = mysql_num_rows($qry1);
		$num = 1;
		$x = 1;
		if ($numrow==0) {
			echo '<tr><th colspan="4">'.$DEV_NO_DATA.'</th></tr>';
		} else {
			while ($row1 = mysql_fetch_object($qry1)) {
				$nama = explode("[spasi]",$row1->data);
				$ukuran = $nama[2];
				$tipe = $row1->tipe;
				if (!empty($nama[3])) $url = $nama[3];
				else $url = "NONE"; 
				$data = $x % 2;
				if ($data==0) $dataX = "ganjil";
				else $dataX = "genap"; 
?>
  <tr valign="top" class="<?php echo $dataX; ?>" onmouseover="setBG('bg<?php echo $x; ?>','#FFFFDD')" onmouseout="setBG('bg<?php echo $x; ?>','')" id="bg<?php echo $x; ?>"> 
    <td><div align="left"><?php echo $nama[1]; ?></div></td>
    <td nowrap="nowrap"><div align="center"><?php echo $queryData->tanggalan($row1->tanggal); ?></div>
    <div align="center"></div></td>
    <td> 
      <div align="center"> 
        <?php
		if (file_exists("data/galeri/FG".$nama[0].".".$row1->tipe)) {
			echo "<a href=\"data/galeri/FG".$nama[0].".".$row1->tipe."\" title=\"Download\"><img src='".DIR_PATH."images/download.gif' border='0'></a>";
		} else {
			echo "Data Tidak ada";
		};
	?>
      </div></td>
		<?php echo $queryData->ctrl_data('','index.php?show='.SHOW.'&showview='.SHOWVIEW.'&act=edit&kode='.$row1->idx,$path.'ver_foto_galeri.php?show='.SHOW.'&amp;showview='.SHOWVIEW.'&amp;kode='.$row1->idx.'&amp;act_ver=Hapus'); ?>
  </tr>
  <?php
				$x++;
				$num++;
			}
		}
?>
</table>
<?php
		echo $queryData->next_prev($num,$pages_syarat,$limitdown);
	}
?>
